import { queryPageList,queryLabelList,updateConfirm,queryDatabaseList} from '@/services/sensitiveData/scanColumn';

export default {
  namespace: 'scanColumn',
  state: {
    // 列表数据
    data: {
      dataList: [],
      pageNum: 0,
      pageSize: 0,
      totalCount: 0,
    },  
    labelData:{},  
    databaseListData:{},    
    queryForm:{},
  },
  effects: {
    *queryList({ payload }, { call, put }) {
      const response = yield call(queryPageList, payload);
      yield put({
        type: 'save',
        payload: response,
      });
    },

    *selectLabelList({ payload,callback }, { call, put }) {
      const response = yield call(queryLabelList, payload);
      yield put({
        type: 'saveLabel',
        payload: response,
      });
      if (callback) callback(response);
    },

    *update({ payload, callback }, { call, put }) {
      const response = yield call(updateConfirm, payload);
      yield put({
        type: 'saveupdate',
        payload: response,
      });
      if (callback) callback(response);
    },

    *selectDatabaseList({ payload,callback }, { call, put }) {
      const response = yield call(queryDatabaseList, payload);
      yield put({
        type: 'saveDatabase',
        payload: response,
      });
      if (callback) callback(response);
    },//查询数据库   

  },

  reducers: {
    save(state, action) {
      return {
        ...state,
        data: action.payload.data || [],
      };
    },
    
    saveLabel(state, action) {
      return {
        ...state,
        labelData: action.payload.data || [],
      };
    },

    saveDatabase(state, action) {
      return {
        ...state,
        databaseListData: action.payload.data || [],
      };
    }, //数据库

  },
};
